package com.bobo.controller;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.bobo.service.impl.ImportExcelUtil;
import com.bobo.vo.Admin;
import com.bobo.vo.InfoVo;

@Controller
@RequestMapping("/login")
public class AdminLoginController {
	@RequestMapping("/adminLogin") 
	public String login(HttpServletRequest request,HttpServletResponse response, HttpSession session,Admin admin) throws ServletException, IOException {
		if(admin != null ) {
			if("admin".equals(admin.getAdminName()) && "admin".equals(admin.getAdminPassword())) {
				System.out.println(admin.getAdminName() +"=====" + admin.getAdminPassword());
				session.setAttribute("adminName", "admin");
				return "/WEB-INF/jsp/adminHandle.jsp";
			} else if(admin.getAdminName() == "" || admin.getAdminPassword() == ""){
				request.setAttribute("err", "用户名或密码不能为空！");
				return "/WEB-INF/jsp/adminLogin.jsp";
			} else {
				request.setAttribute("err", "用户名或密码错误！");
				return "/WEB-INF/jsp/adminLogin.jsp";
			}
		}else {
			request.setAttribute("err", "用户名或密码不能为空！");
			return "/WEB-INF/jsp/adminLogin.jsp";
		}
	}
	
	@RequestMapping("/welcome")
	public String upload(){
		return "/WEB-INF/jsp/welcome.jsp";
	}
	
}
